﻿@model HtmlContent.Models.Page

@{
    ViewBag.Title = "Edit HTML Page";
    List<HtmlContent.Models.Permission> plist = ViewBag.PermissionList;
    List<Core.NameId> lYesNo = Core.Tools.YesNo();
}

<h1>@ViewBag.Title</h1>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(false)
    <table border="0" cellpadding="5" cellspacing="0" width="100%">
    <tr><td valign="top">
    <fieldset>
        <legend>Page Info</legend>
        @Html.HiddenFor(model => model.PageId)
        @Html.HiddenFor(model => model.BusinessUnitId)
        @Html.HiddenFor(model => model.ContainerId)
        @Html.HiddenFor(model => model.HtmlPageId)
        @Html.HiddenFor(model => model.HtmlContentId)

        <div class="editor-label">
            @Html.LabelFor(model => model.Title)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.Title, new { size="50"})
        </div>

        <div style="float:left">
        <div class="editor-label">
            @Html.LabelFor(model => model.ShowTitleYN)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.ShowTitleYN,new SelectList(lYesNo,"Id","Name",Model.ShowTitleYN))
        </div>
        </div>

        <div style="float:left;padding-left:20px">
        <div class="editor-label">
            @Html.LabelFor(model => model.OnMainMenuYN)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.OnMainMenuYN,new SelectList(lYesNo,"Id","Name",Model.OnMainMenuYN))
        </div>
        </div>
        <div style="clear:left" />

        <div class="editor-label">
            @Html.LabelFor(model => model.PermissionId)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.PermissionId,new SelectList(plist,"PermissionId","Name",Model.PermissionId))
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.PageName)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.PageName, new { size="50"})
        </div>
    </fieldset>
    </td><td valign="top">
    <fieldset>
    <legend>Meta Information</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.MetaKeywords)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.MetaKeywords, new { rows = "4", cols = "35" })
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.MetaDescription)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.MetaDescription, new { rows="4", cols="35"})
        </div>
    </fieldset>
    </td></tr>    
    <tr><td colspan="2">
        <div class="editor-field" id="ContentEditor">
            @Html.TextAreaFor(model => model.ContentText, new { cols = "40", rows = "5" })
			<script type="text/javascript">
			//<![CDATA[
			    CKEDITOR.replace('ContentText',
					{
					    toolbar: 'Editor',
					    skin: 'v2',
                        height: '400px'                        
					});
			//]]>
			</script>
        </div>
    </td></tr>
    <tr><td colspan="2">
    &nbsp;
    </td></tr>
    <tr><td colspan="2">
        <input type="submit" value="Save" /> |
        @Html.ActionLink("Back to List", "Index")
    </td></tr>
    </table>
}
<script type="text/javascript" language="javascript">
    $(document).ready(function () {
        $('#AdvancedYN').change(function () {
            if ($('#AdvancedYN').val() == 'Y')
                $('#ContentEditor').hide();
            else
                $('#ContentEditor').show();
        });

        $('#Title').change(function () {
            var pagename = $('#Title').val().toLowerCase().replace(/[^a-z0-9]+/g, " ");
            pagename = "~/" + pagename.trim().replace(/\s+/g, "-") + ".html";
            $('#PageName').val(pagename);
        });
    });
</script>
